package mvc.struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {

	public FullForm()
	{
		
	}
	
	/**
	 * 
	 */
	public static ActionForm full(String formClass, HttpServletRequest request)
	{
		ActionForm	form = null;
		
		try 
		{
			Class	classZ = Class.forName(formClass);
			
			form = (ActionForm)classZ.newInstance();
			
			Field[]	field_array  = classZ.getDeclaredFields();
						
			for	(Field field : field_array)
			{
				field.setAccessible(true);
				
				field.set(form, request.getAttribute(field.getName()));
				
				field.setAccessible(false);
			}
		} 
		catch (Exception ex) {
		
			ex.printStackTrace();
		}
		
		return	form;
	}
}
